<?php

namespace app\controllers;

use app\core\helpers\DateHelper;
use Exception;
use Yii;

class UserController extends ApiController
{
    /**
     * @throws Exception
     */
    public function actionData(): array
    {
        $user = Yii::$app->user->identity->user;

        return [
            'username' => $user->username,
            'email' => $user->email,
            'avatar' => Yii::$app->avatar->show(Yii::$app->user->identity->user->username . '_' . Yii::$app->user->id),
            'date' => [
                'created' => DateHelper::formatApi($user->created_at),
                'updated' => DateHelper::formatApi($user->updated_at),
            ],
            'status' => [
                'code' => $user->status
            ],
        ];
    }
}
